<template>
	<view>
		<view class="cu-card article no-card">
			<view class="cu-item shadow borderBottom" v-for="(item, index) in list" :key="index"
				@click="goNews(item.id)">
				<blogItem :item="item"></blogItem>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '@/common/request.js'
	export default {
		mounted() {
			this.getBlogList();
		},
		onTabItemTap() {
			this.getBlogList();
		},
		data() {
			return {
				list: [],
				scrollTop: 0,
				old: {
					scrollTop: 0
				}
			};
		},
		methods: {
			upper: function(e) {
				console.log(e)
			},
			lower: function(e) {
				console.log(e)
			},
			scroll: function(e) {
				console.log(e)
				this.old.scrollTop = e.detail.scrollTop
			},
			goTop: function(e) {
				// 解决view层不同步的问题
				this.scrollTop = this.old.scrollTop
				this.$nextTick(function() {
					this.scrollTop = 0
				});
				uni.showToast({
					icon: "none",
					title: "纵向滚动 scrollTop 值已被修改为 0"
				})
			},
			getBlogList() {
				request.httpRequest({
					url: 'wx/getBlogList',
					method: 'POST'
				}, {
					pageNumber: 1,
					pageSize: 20,
					sortOrder: 'asc',
					title: '',
					status: '1',
				}).then(res => {
					this.list = res.rows
				})
			},
			goNews(id) {
				uni.navigateTo({
					url: '/pages/list/detail?id=' + id
				})
			}
		}
	}
</script>

<style lang="scss">
</style>